<!-- 我的 – 基本信息		basic -->
<template>
	<view class="">
		<view class="basic-box pt5 pb10">
			<view class="w90" style="padding-top:22rpx;">
				<view class=" f flex-between c">
					<view class="fs24 fw600 wd15">姓名：</view>
					<view class="fs24 c-666 ellipsis wd85 right">{{data.name}}</view>
				</view>
				<view class="quanxian m_t_30"></view>
			</view>
			<view class="w90" style="padding-top:22rpx;" v-if="data.type">
				<view class=" f  c flex-between">
					<text class="fs24 fw600">职位：</text>
					<text class="fs24 c-666" v-if="data.type==1">老板</text>
					<text class="fs24 c-666" v-if="data.type==2">店长</text>
					<text class="fs24 c-666" v-if="data.type==3">教练</text>
					<text class="fs24 c-666" v-if="data.type==4">前台</text>
				</view>
				<view class="quanxian m_t_30"></view>
			</view>
			<view class="w90" style="padding-top:22rpx;">
				<view class=" f  c flex-between">
					<text class="fs24 fw600">手机号：</text>
					<text class="fs24 c-666">{{data.phone?data.phone:'无'}}</text>
				</view>
				<view class="quanxian m_t_30"></view>
			</view>
			<view class="w90" style="padding-top:22rpx;">
				<view class=" f  c flex-between">
					<text class="fs24 fw600">加入时间：</text>
					<text class="fs24 c-666">{{data.create_time | fengetime}}</text>
				</view>
				<view class=" m_t_30"></view>
			</view>
		</view>
		
		<view class="text-area mb10 " @click="qiehuan" v-if="is_duoUser">
			<view class="but center" style="background-color: #CDE9FF">切换用户</view>
		</view>
		<u-popup v-model="show" mode="center" width="80%" border-radius="20">
			<view class="center" >
				<view class="bb" style="height: 100rpx;line-height: 100rpx;">
					选择用户
				</view>
				<view class=" pb20 dis-flex flex-wrap">
					<view @click="gouser(item)" class="wd50 mt20" v-for="(item,index) in userList">
						<image :src="item.img" mode="" style="border-radius: 200rpx;width: 130rpx;height: 130rpx;"></image>
						<view class="c-999 fs26 mt5 ellipsis pl20 pr20">
							{{item.name}}
						</view>
					</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data:[],
				show:false,
				userList:[],
				is_duoUser:false
			}
		},
		onLoad(e) {
			// 动态导航条文字
			uni.setNavigationBarTitle({
				title: '基本信息'
			})
			this.data = JSON.parse(decodeURIComponent(e.data));
			this.init()
		},
		methods: {
			init(){
				var that = this
				var json={
					token: uni.getStorageSync('token'),
				}
				that.$http.post(that.$config.UrlPostuserList, json).then((res) => {
					if (res.status == 1 && res.data.length > 1) {
						that.is_duoUser = true
						that.userList = res.data
					}
				})
			},
			//选择用户
			gouser(item){
				var that = this
				uni.login({
					provider: 'weixin',
					success: function(loginRes) {
						var json={
							code: loginRes.code,
							token:item.token
						}
						that.$http.post(that.$config.UrlPostselectUser, json).then((res) => {
							if (res.status == 1 ) {
								uni.setStorageSync('token', item.token);
								that.$api.toast('切换成功')
								setTimeout(()=>{
									that.$api.openWindow('/pages/mine/mine','switchTab')
								},500)
							}
						})
					}
				});
			},
			qiehuan(){
				this.show = !this.show
			}
		}
	}
</script>

<style scoped>
	.warps {
		height:95vh;
		overflow: hidden;
		background-color: #F6F8FC;
	}
	.basic-box{
		width: 686rpx;
		opacity: 1;
		background: #ffffff;
		border-radius: 16rpx;
		box-shadow: 0rpx 0rpx 12rpx 0rpx rgba(0,0,0,0.16); 
		margin:0 auto;
		margin-top:32rpx;
	}
	.ipts{
		width:200rpx;
		height: 34rpx;
		font-size:24rpx;
	}
	.text-area {
		display: flex;
		justify-content: center;
		margin-top:80rpx;
	}
	.but{
		width: 600rpx;
		height: 76rpx;
		line-height:76rpx;
		opacity: 1;
		background: #1f73f2;
		border-radius: 16rpx;
		font-size:28rpx;
		color:#fff;
	}
</style>
